/**
 * 工作报告相关类型定义
 */

// 工作记录状态
export enum WorkRecordStatus {
  PENDING = 'PENDING',
  IN_PROGRESS = 'IN_PROGRESS',
  COMPLETED = 'COMPLETED',
  CANCELLED = 'CANCELLED'
}

// 工作记录优先级
export enum WorkRecordPriority {
  LOW = 'LOW',
  MEDIUM = 'MEDIUM',
  HIGH = 'HIGH',
  URGENT = 'URGENT'
}

// 报告类型
export enum ReportType {
  DAILY = 'DAILY',
  WEEKLY = 'WEEKLY',
  MONTHLY = 'MONTHLY'
}

// 报告状态
export enum ReportStatus {
  DRAFT = 'DRAFT',
  FINAL = 'FINAL',
  ARCHIVED = 'ARCHIVED'
}

// 工作分类
export interface WorkCategory {
  id?: number
  userId?: number
  name: string
  description?: string
  color: string
  icon: string
  isSystem: boolean
  createdAt?: string
}

// 工作记录
export interface WorkRecord {
  id?: number
  userId: number
  date: string
  title: string
  content?: string
  categoryId?: number
  categoryName?: string
  categoryColor?: string
  categoryIcon?: string
  status: WorkRecordStatus
  statusDescription?: string
  priority: WorkRecordPriority
  priorityDescription?: string
  timeSpent: number // 分钟
  tags: string[]
  createdAt?: string
  updatedAt?: string
}

// 创建工作记录请求
export interface CreateWorkRecordRequest {
  date: string
  title: string
  content?: string
  categoryId?: number
  status?: WorkRecordStatus
  priority?: WorkRecordPriority
  timeSpent?: number
  tags?: string[]
}

// 更新工作记录请求
export interface UpdateWorkRecordRequest {
  date?: string
  title?: string
  content?: string
  categoryId?: number
  status?: WorkRecordStatus
  priority?: WorkRecordPriority
  timeSpent?: number
  tags?: string[]
}

// 生成报告请求
export interface GenerateReportRequest {
  type: ReportType
  startDate: string
  endDate?: string
}

// 生成的报告响应
export interface GeneratedReportResponse {
  type: ReportType
  typeDescription: string
  startDate: string
  endDate?: string
  content: string
  recordCount: number
  totalTimeSpent: number // 分钟
  formattedTimeSpent: string
  generatedAt: string
  title?: string
}

// 工作记录查询参数
export interface WorkRecordQueryParams {
  page?: number
  size?: number
  date?: string
  startDate?: string
  endDate?: string
  categoryId?: number
  status?: WorkRecordStatus
}

// 分页响应
export interface PageResponse<T> {
  content: T[]
  totalElements: number
  totalPages: number
  size: number
  number: number
  first: boolean
  last: boolean
}

// 状态选项
export const STATUS_OPTIONS = [
  { label: '待处理', value: WorkRecordStatus.PENDING, color: '#909399' },
  { label: '进行中', value: WorkRecordStatus.IN_PROGRESS, color: '#409EFF' },
  { label: '已完成', value: WorkRecordStatus.COMPLETED, color: '#67C23A' },
  { label: '已取消', value: WorkRecordStatus.CANCELLED, color: '#F56C6C' }
]

// 优先级选项
export const PRIORITY_OPTIONS = [
  { label: '低', value: WorkRecordPriority.LOW, color: '#909399' },
  { label: '中', value: WorkRecordPriority.MEDIUM, color: '#409EFF' },
  { label: '高', value: WorkRecordPriority.HIGH, color: '#E6A23C' },
  { label: '紧急', value: WorkRecordPriority.URGENT, color: '#F56C6C' }
]

// 报告类型选项 - 使用函数支持国际化
export const createReportTypeOptions = (t: (key: string) => string) => [
  {
    label: t('workReports.generate.reportTypes.daily'),
    value: ReportType.DAILY,
    description: t('workReports.generate.reportTypeDescriptions.daily')
  },
  {
    label: t('workReports.generate.reportTypes.weekly'),
    value: ReportType.WEEKLY,
    description: t('workReports.generate.reportTypeDescriptions.weekly')
  },
  {
    label: t('workReports.generate.reportTypes.monthly'),
    value: ReportType.MONTHLY,
    description: t('workReports.generate.reportTypeDescriptions.monthly')
  }
]

// 兼容性：保留原有的静态导出（已弃用，建议使用createReportTypeOptions）
export const REPORT_TYPE_OPTIONS = [
  { label: '日报', value: ReportType.DAILY, description: '生成指定日期的工作日报' },
  { label: '周报', value: ReportType.WEEKLY, description: '生成指定周期的工作周报' },
  { label: '月报', value: ReportType.MONTHLY, description: '生成指定月份的工作月报' }
]

// 默认分类图标
export const DEFAULT_CATEGORY_ICONS = [
  'folder', 'code', 'bug', 'meeting', 'study', 'document', 'server', 'other',
  'edit', 'setting', 'star', 'heart', 'flag', 'bookmark', 'tag', 'clock'
]

// 默认分类颜色
export const DEFAULT_CATEGORY_COLORS = [
  '#409EFF', '#67C23A', '#E6A23C', '#F56C6C', '#9C27B0', '#00BCD4',
  '#4CAF50', '#FF9800', '#795548', '#607D8B', '#E91E63', '#3F51B5'
]

// ==================== 报告管理相关类型 ====================

// 生成的报告实体
export interface GeneratedReport {
  id: number
  title: string
  type: ReportType
  typeDisplayName: string
  periodStart: string
  periodEnd: string
  status: ReportStatus
  statusDisplayName: string
  version: number
  isEdited: boolean
  tags: string[]
  createdAt: string
  updatedAt: string
  contentPreview?: string
  originalContent?: string
  editedContent?: string
  currentContent?: string
}

// 报告查询请求
export interface ReportQueryRequest {
  page?: number
  size?: number
  type?: ReportType
  status?: ReportStatus
  keyword?: string
  startDate?: string
  endDate?: string
  sortBy?: string
  sortDirection?: 'ASC' | 'DESC'
}

// 报告更新请求
export interface ReportUpdateRequest {
  title: string
  editedContent: string
  status: ReportStatus
  tags?: string[]
}

// 批量操作请求
export interface BatchOperationRequest {
  reportIds: number[]
  operation: 'DELETE' | 'ARCHIVE' | 'EXPORT'
}

// 报告导出请求
export interface ReportExportRequest {
  reportId: number
  format: 'PDF' | 'WORD' | 'MARKDOWN'
  includeOriginal?: boolean
}

// 报告统计信息
export interface ReportStats {
  totalReports: number
  typeStats: Record<string, number>
  statusStats: Record<string, number>
  recentTrend: DailyStatsItem[]
  monthlyTrend: MonthlyStatsItem[]
}

// 日统计项
export interface DailyStatsItem {
  date: string
  count: number
}

// 月统计项
export interface MonthlyStatsItem {
  year: number
  month: number
  count: number
}

// 报告筛选器
export interface ReportFilters {
  type?: ReportType
  status?: ReportStatus
  keyword?: string
  startDate?: string
  endDate?: string
}

// 分页信息
export interface PaginationInfo {
  page: number
  size: number
  total: number
  totalPages: number
}

// 报告状态选项
export const REPORT_STATUS_OPTIONS = [
  { label: '草稿', value: ReportStatus.DRAFT, color: '#909399' },
  { label: '最终版', value: ReportStatus.FINAL, color: '#67C23A' },
  { label: '已归档', value: ReportStatus.ARCHIVED, color: '#E6A23C' }
]

// 导出格式选项
export const EXPORT_FORMAT_OPTIONS = [
  { label: 'PDF', value: 'PDF', icon: 'document' },
  { label: 'Word', value: 'WORD', icon: 'edit' },
  { label: 'Markdown', value: 'MARKDOWN', icon: 'code' }
]

// 排序选项
export const SORT_OPTIONS = [
  { label: '创建时间', value: 'createdAt' },
  { label: '更新时间', value: 'updatedAt' },
  { label: '报告标题', value: 'title' },
  { label: '报告类型', value: 'type' },
  { label: '时间范围', value: 'periodStart' }
]
